package user

import (
	"github.com/bgmp/config"
	"github.com/bgmp/handler"
	"github.com/bgmp/middleware"
	"github.com/bgmp/model"
	"github.com/gin-gonic/gin"
	log "github.com/sirupsen/logrus"
)

func (b Base) UpdateCaseHistory(c *gin.Context, req *UpdateCaseHistoryRequest) *UpdateCaseHistoryResponse {
	ch := &model.CaseHistory{}
	ch.UserId = middleware.GetUserId(c)
	err := ch.Get(config.DB)
	if err != nil {
		handler.Errorf(c, "病程信息不存在")
		return nil
	}
	ch.CaseHistoryField = req.CaseHistoryField
	err = ch.Save(config.DB)
	if err != nil {
		handler.Errorf(c, "更新病程信息失败")
		log.Error(err)
		return nil
	}
	return &UpdateCaseHistoryResponse{}
}

type UpdateCaseHistoryRequest struct {
	model.CaseHistoryField
}

type UpdateCaseHistoryResponse struct {
}
